<template>
	<view class="contain u-content">
		<view><u-parse :content="content" :tagStyle="style"></u-parse></view>
	</view>
</template>

<script setup lang='ts'>
import { ref,reactive } from 'vue'
import {  onLoad } from '@dcloudio/uni-app'

let articleType=ref("课程介绍");

let content=ref(`<p>露从今夜白，月是故乡明</p><img src="https://cdn.uviewui.com/uview/swiper/2.jpg" />`);
let style=reactive({
		// 字符串的形式
		p: 'color: red;font-size:32rpx; line-height:50rpx; margin-bottom:5px !important;',
		span: 'font-size: 30rpx'
})

onLoad((e:any)=>{
	if(e.aType!=null){
		console.log("文章内容",e.aType);
		getArticles(e.aType);
		uni.setNavigationBarTitle({
			title:e.aType
		})
	}
});


/* 获取文章 */
const getArticles=(articleType:string)=>{
	let paraData={
		atype:articleType
	}
	uni.$tools.Reqeust('/api/getArticles',paraData,'POST').then((res:any)=>{
		console.log('获取文章结果:==>',res);
		if (res.data.code == 200) {
			uni.hideLoading();
			content.value=res.data.data.bodydata;
		}else{
			uni.hideLoading();
		}
	})	
}


</script>
<style lang='scss' scoped>
	@import "article.scss";
	.u-content {
		padding: 10rpx;
	}
</style>